<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/mayioa/css/mayioa-ui.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/datapicker/bootstrap-datetimepicker.min.css}" rel="stylesheet"/>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-plan-class-edit" th:object="${planClass}">
			<input name="planClassId"  type="hidden"  th:field="*{planClassId}" />

			<div class="form-group">
				<label class="col-sm-3 control-label">课程名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="planClassName" id="planClassName" th:field="*{planClassName}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">课程描述：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="planClassDesc" id="planClassDesc" th:field="*{planClassDesc}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">课程总分：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="planClassTotalScore" id="planClassTotalScore" th:field="*{planClassTotalScore}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">通过分数：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="planClassPassScore" id="planClassPassScore" th:field="*{planClassPassScore}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">课程老师：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="planClassTeacher" id="planClassTeacher" th:field="*{planClassTeacher}">
				</div>
			</div>

			
			<div class="form-group">
					<label class="col-sm-3 control-label">课程开始时间：</label>
					<div class="col-sm-8" style="padding: 0 28px;">
						<div class="form-group">
							<div class="input-group date"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
								<input type="text" id="planClassBeginTime" name="planClassBeginTime" class="form-control"  th:value="${#dates.format(planClass.planClassBeginTime,'yyyy-MM-dd HH:mm:ss')}" style="background:#fff;">
							</div>
						</div>
					</div>
			</div>
	

			<div class="form-group">
					<label class="col-sm-3 control-label">课程结束时间：</label>
					<div class="col-sm-8" style="padding: 0 28px;">
						<div class="form-group">
							<div class="input-group date"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
								<input type="text" id="planClassEndTime" name="planClassEndTime" class="form-control"  th:value="${#dates.format(planClass.planClassEndTime,'yyyy-MM-dd HH:mm:ss')}" style="background:#fff;">
							</div>
						</div>
					</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">课程类型：</label>
				<div class="col-sm-8">
					<select id="planClassType" class="form-control m-b" th:with="type=${@dict.getType('plan_class_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{planClassType}"></option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
	<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
	<script th:src="@{/ajax/libs/datapicker/bootstrap-datetimepicker.min.js}"></script>
	<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
	<script>
	 $.fn.datetimepicker.dates['zh-CN'] = {
             days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
             daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
             daysMin:  ["日", "一", "二", "三", "四", "五", "六", "日"],
             months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
             monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
             today: "今日",
             suffix: [],
             meridiem: ["上午", "下午"],
             weekStart: 1
     };
	 $("#planClassBeginTime").datetimepicker({
			language:"zh-CN",
		    format: "yyyy-mm-dd hh:ii",
		    language: 'zh-CN',
		    todayHighlight:true,
		    startDate:new Date(),
		    autoclose: true ,
		    keyboardNavigation: !1,
			forceParse: !1,
			todayBtn: "linked",
			calendarWeeks: !0
		}).on('changeDate',function(ev){
			  var starttime=$("#planClassBeginTime").val();
			  $("#planClassEndTime").datetimepicker('setStartDate',starttime);
			  $("#planClassBeginTime").datetimepicker('hide');
	    });
			
		$("#planClassEndTime").datetimepicker({
			 language:"zh-CN",
			 format: "yyyy-mm-dd hh:ii", 
			 language: 'zh-CN',
			 todayHighlight:true,
			 startDate:new Date(),
			 autoclose: true ,
			 keyboardNavigation: !1,
			 forceParse: !1,
			 todayBtn: "linked",
			 calendarWeeks: !0
		}).on('changeDate',function(ev){
			  var starttime=$("#planClassBeginTime").val();
			  var endtime=$("#planClassEndTime").val();
			  $("#planClassBeginTime").datetimepicker('setEndDate',endtime);
			  $("#planClassEndTime").datetimepicker('hide'); 
		});

        $("#form-plan-class-edit").validate({
        	rules:{
        		planClassName:{
        			required:true
        		},
        		planClassTotalScore:{
        			required:true,
        			digits:true
        		},
        		planClassPassScore:{
        			required:true,
        			digits:true
        		}
			}
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }

        function edit() {
        	var planClassId = $("input[name='planClassId']").val();
        	var planClassName = $("input[name='planClassName']").val();
        	var planClassDesc = $("input[name='planClassDesc']").val();
        	var planClassTotalScore = $("input[name='planClassTotalScore']").val();
        	var planClassPassScore = $("input[name='planClassPassScore']").val();
        	var planClassTeacher = $("input[name='planClassTeacher']").val();
        	var planClassBeginTime = $("input[name='planClassBeginTime']").val();
        	var planClassEndTime = $("input[name='planClassEndTime']").val();
        	var planClassType = $("#planClassType option:selected").val();

        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "plan/class/edit",
        		data : {
        			"planClassId": planClassId,
        			"planClassName": planClassName,
        			"planClassDesc": planClassDesc,
        			"planClassTotalScore": planClassTotalScore,
        			"planClassPassScore": planClassPassScore,
        			"planClassTeacher": planClassTeacher,
        			"planClassBeginTime": planClassBeginTime,
        			"planClassEndTime": planClassEndTime,
        			"planClassType": planClassType
        		},
        		async : false,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
    </script>
</body>
</html>
